import {
  BwComPropSetConstValueComEnum,
  BwCustomComPropDataTypeEnum,
  BwCustomComEmitParamDataTypeEnum,
  BwCustomComSlotParamDataTypeEnum,
  BwCustomComSoltTypeEnum,
} from '../../../render/models'
import type {
  BwCustomComEmitInfoModel,
  BwCustomComSlotInfoModel,
  BwCustomComPropInfoModel,
} from '../../../render/models'

/** 组件属性 */
const comAttrs: Array<BwCustomComPropInfoModel> = [
  {
    key: 'class',
    name: 'classNames',
    isRequire: false,
    defaultValue: undefined,
    dataType: [
      BwCustomComPropDataTypeEnum.string,
      BwCustomComPropDataTypeEnum.array,
    ],
    defaultValueDataType: BwCustomComPropDataTypeEnum.string,
    constValueSetCom: BwComPropSetConstValueComEnum.input,
    constValueSetComProps: null,
    remark: '',
  },
  // {
  //   key: 'allowDrop',
  //   name: '是否允许拖拽时放置在该节点',
  //   isRequire: false,
  //   defaultValue: undefined,
  //   dataType: [BwCustomComPropDataTypeEnum.function],
  //   defaultValueDataType: BwCustomComPropDataTypeEnum.function,
  //   constValueSetCom: BwComPropSetConstValueComEnum.function,
  //   constValueSetComProps: null,
  //   remark: '',
  // },
  {
    key: 'autoExpandParent',
    name: '是否自动展开父节点',
    isRequire: false,
    defaultValue: 'false',
    dataType: [BwCustomComPropDataTypeEnum.boolean],
    defaultValueDataType: BwCustomComPropDataTypeEnum.boolean,
    constValueSetCom: BwComPropSetConstValueComEnum.switch,
    constValueSetComProps: null,
    remark: '',
  },
  {
    key: 'blockNode',
    name: '是否节点占据一行',
    isRequire: false,
    defaultValue: 'false',
    dataType: [BwCustomComPropDataTypeEnum.boolean],
    defaultValueDataType: BwCustomComPropDataTypeEnum.boolean,
    constValueSetCom: BwComPropSetConstValueComEnum.switch,
    constValueSetComProps: null,
    remark: '',
  },
  {
    key: 'checkable',
    name: '节点前添加 Checkbox 复选框',
    isRequire: false,
    defaultValue: 'false',
    dataType: [BwCustomComPropDataTypeEnum.boolean],
    defaultValueDataType: BwCustomComPropDataTypeEnum.boolean,
    constValueSetCom: BwComPropSetConstValueComEnum.switch,
    constValueSetComProps: null,
    remark: '',
  },
  {
    key: 'checkedKeys',
    name: '(受控)选中复选框的树节点(v-model)',
    isModel: true,
    isRequire: false,
    defaultValue: '[]',
    dataType: [BwCustomComPropDataTypeEnum.array],
    defaultValueDataType: BwCustomComPropDataTypeEnum.array,
    constValueSetCom: BwComPropSetConstValueComEnum.textarea,
    constValueSetComProps: null,
    remark: '',
  },
  {
    key: 'checkStrictly',
    name: 'checkable 状态下节点选择完全受控',
    isRequire: false,
    defaultValue: 'false',
    dataType: [BwCustomComPropDataTypeEnum.boolean],
    defaultValueDataType: BwCustomComPropDataTypeEnum.boolean,
    constValueSetCom: BwComPropSetConstValueComEnum.switch,
    constValueSetComProps: null,
    remark: '',
  },
  {
    key: 'defaultExpandAll',
    name: '默认展开所有树节点',
    isRequire: false,
    defaultValue: 'false',
    dataType: [BwCustomComPropDataTypeEnum.boolean],
    defaultValueDataType: BwCustomComPropDataTypeEnum.boolean,
    constValueSetCom: BwComPropSetConstValueComEnum.switch,
    constValueSetComProps: null,
    remark: '',
  },
  {
    key: 'disabled',
    name: '将树禁用',
    isRequire: false,
    defaultValue: 'false',
    dataType: [BwCustomComPropDataTypeEnum.boolean],
    defaultValueDataType: BwCustomComPropDataTypeEnum.boolean,
    constValueSetCom: BwComPropSetConstValueComEnum.switch,
    constValueSetComProps: null,
    remark: '',
  },
  {
    key: 'draggable',
    name: '设置节点可拖拽',
    isRequire: false,
    defaultValue: 'false',
    dataType: [BwCustomComPropDataTypeEnum.boolean],
    defaultValueDataType: BwCustomComPropDataTypeEnum.boolean,
    constValueSetCom: BwComPropSetConstValueComEnum.switch,
    constValueSetComProps: null,
    remark: '',
  },
  {
    key: 'expandedKeys',
    name: '（受控）展开指定的树节点(v-model)',
    isModel: true,
    isRequire: false,
    defaultValue: '[]',
    dataType: [BwCustomComPropDataTypeEnum.array],
    defaultValueDataType: BwCustomComPropDataTypeEnum.array,
    constValueSetCom: BwComPropSetConstValueComEnum.textarea,
    constValueSetComProps: null,
    remark: '',
  },
  {
    key: 'fieldNames',
    name: '替换字段',
    isRequire: false,
    defaultValue: JSON.stringify({
      children: 'children',
      title: 'title',
      key: 'key',
    }),
    dataType: [BwCustomComPropDataTypeEnum.object],
    defaultValueDataType: BwCustomComPropDataTypeEnum.object,
    constValueSetCom: BwComPropSetConstValueComEnum.textarea,
    constValueSetComProps: null,
    remark: '',
  },
  // {
  //   key: 'filterTreeNode',
  //   name: '按需筛选树节点（高亮），返回 true',
  //   isRequire: false,
  //   defaultValue: undefined,
  //   dataType: [BwCustomComPropDataTypeEnum.function],
  //   defaultValueDataType: BwCustomComPropDataTypeEnum.function,
  //   constValueSetCom: BwComPropSetConstValueComEnum.function,
  //   constValueSetComProps: null,
  //   remark: '',
  // },
  {
    key: 'height',
    name: '设置虚拟滚动容器高度',
    isRequire: false,
    defaultValue: undefined,
    dataType: [BwCustomComPropDataTypeEnum.number],
    defaultValueDataType: BwCustomComPropDataTypeEnum.number,
    constValueSetCom: BwComPropSetConstValueComEnum.number,
    constValueSetComProps: null,
    remark: '',
  },
  // {
  //   key: 'loadData',
  //   name: '异步加载数据',
  //   isRequire: false,
  //   defaultValue: undefined,
  //   dataType: [BwCustomComPropDataTypeEnum.function],
  //   defaultValueDataType: BwCustomComPropDataTypeEnum.function,
  //   constValueSetCom: BwComPropSetConstValueComEnum.function,
  //   constValueSetComProps: null,
  //   remark: '',
  // },
  {
    key: 'loadedKeys',
    name: '（受控）已经加载的节点',
    isRequire: false,
    defaultValue: '[]',
    dataType: [BwCustomComPropDataTypeEnum.array],
    defaultValueDataType: BwCustomComPropDataTypeEnum.array,
    constValueSetCom: BwComPropSetConstValueComEnum.textarea,
    constValueSetComProps: null,
    remark: '',
  },
  {
    key: 'multiple',
    name: '支持点选多个节点',
    isRequire: false,
    defaultValue: 'false',
    dataType: [BwCustomComPropDataTypeEnum.boolean],
    defaultValueDataType: BwCustomComPropDataTypeEnum.boolean,
    constValueSetCom: BwComPropSetConstValueComEnum.switch,
    constValueSetComProps: null,
    remark: '',
  },
  {
    key: 'selectable',
    name: '是否可选中',
    isRequire: false,
    defaultValue: 'true',
    dataType: [BwCustomComPropDataTypeEnum.boolean],
    defaultValueDataType: BwCustomComPropDataTypeEnum.boolean,
    constValueSetCom: BwComPropSetConstValueComEnum.switch,
    constValueSetComProps: null,
    remark: '',
  },
  {
    key: 'selectedKeys',
    name: '（受控）设置选中的树节点(v-model)',
    isModel: true,
    isRequire: false,
    defaultValue: undefined,
    dataType: [BwCustomComPropDataTypeEnum.array],
    defaultValueDataType: BwCustomComPropDataTypeEnum.array,
    constValueSetCom: BwComPropSetConstValueComEnum.textarea,
    constValueSetComProps: null,
    remark: '',
  },
  {
    key: 'showIcon',
    name: '是否展示 TreeNode title 前的图标，没有默认样式，如设置为 true，需要自行定义图标相关样式',
    isRequire: false,
    defaultValue: 'false',
    dataType: [BwCustomComPropDataTypeEnum.boolean],
    defaultValueDataType: BwCustomComPropDataTypeEnum.boolean,
    constValueSetCom: BwComPropSetConstValueComEnum.switch,
    constValueSetComProps: null,
    remark: '',
  },
  {
    key: 'showLine',
    name: '是否展示连接线',
    isRequire: false,
    defaultValue: 'false',
    dataType: [
      BwCustomComPropDataTypeEnum.boolean,
      BwCustomComPropDataTypeEnum.object,
    ],
    defaultValueDataType: BwCustomComPropDataTypeEnum.boolean,
    constValueSetCom: BwComPropSetConstValueComEnum.switch,
    constValueSetComProps: null,
    remark: '',
  },
  {
    key: 'treeData',
    name: 'treeNodes 数据，如果设置则不需要手动构造 TreeNode 节点(key 在整个树范围内唯一)',
    isRequire: false,
    defaultValue: undefined,
    dataType: [BwCustomComPropDataTypeEnum.array],
    defaultValueDataType: BwCustomComPropDataTypeEnum.array,
    constValueSetCom: BwComPropSetConstValueComEnum.textarea,
    constValueSetComProps: null,
    remark: '',
  },
  {
    key: 'virtual',
    name: '虚拟滚动',
    isRequire: false,
    defaultValue: 'true',
    dataType: [BwCustomComPropDataTypeEnum.boolean],
    defaultValueDataType: BwCustomComPropDataTypeEnum.boolean,
    constValueSetCom: BwComPropSetConstValueComEnum.switch,
    constValueSetComProps: null,
    remark: '',
  },
]

/** 组件事件 */
const comEmits: Array<BwCustomComEmitInfoModel> = [
  {
    key: 'update:checkedKeys',
    name: '选中复选框的树节点',
    isModel: true,
    params: [
      {
        paramKey: 'value',
        paramName: '选中复选框的树节点',
        paramDataType: BwCustomComEmitParamDataTypeEnum.array,
        remark: '',
      },
    ],
  },
  {
    key: 'update:expandedKeys',
    name: '展开指定的树节点',
    isModel: true,
    params: [
      {
        paramKey: 'value',
        paramName: '展开指定的树节点',
        paramDataType: BwCustomComEmitParamDataTypeEnum.array,
        remark: '',
      },
    ],
  },
  {
    key: 'update:selectedKeys',
    name: '设置选中的树节点',
    isModel: true,
    params: [
      {
        paramKey: 'value',
        paramName: '设置选中的树节点',
        paramDataType: BwCustomComEmitParamDataTypeEnum.array,
        remark: '',
      },
    ],
  },
  {
    key: 'check',
    name: '点击复选框触发',
    params: [
      {
        paramKey: 'checkedKeys',
        paramName: 'checkedKeys',
        paramDataType: BwCustomComEmitParamDataTypeEnum.array,
        remark: '',
      },
      {
        paramKey: 'e',
        paramName: 'e',
        paramDataType: BwCustomComEmitParamDataTypeEnum.object,
        remark: '',
      },
    ],
  },
  {
    key: 'dragend',
    name: 'dragend 触发时调用',
    params: [
      {
        paramKey: 'params',
        paramName: 'params',
        paramDataType: BwCustomComEmitParamDataTypeEnum.object,
        remark: '',
      },
    ],
  },
  {
    key: 'dragenter',
    name: 'dragenter 触发时调用',
    params: [
      {
        paramKey: 'params',
        paramName: 'params',
        paramDataType: BwCustomComEmitParamDataTypeEnum.object,
        remark: '',
      },
    ],
  },
  {
    key: 'dragleave',
    name: 'dragleave 触发时调用',
    params: [
      {
        paramKey: 'params',
        paramName: 'params',
        paramDataType: BwCustomComEmitParamDataTypeEnum.object,
        remark: '',
      },
    ],
  },
  {
    key: 'dragover',
    name: 'dragover 触发时调用',
    params: [
      {
        paramKey: 'params',
        paramName: 'params',
        paramDataType: BwCustomComEmitParamDataTypeEnum.object,
        remark: '',
      },
    ],
  },
  {
    key: 'dragstart',
    name: '开始拖拽时调用',
    params: [
      {
        paramKey: 'params',
        paramName: 'params',
        paramDataType: BwCustomComEmitParamDataTypeEnum.object,
        remark: '',
      },
    ],
  },
  {
    key: 'drop',
    name: 'drop 触发时调用',
    params: [
      {
        paramKey: 'params',
        paramName: 'params',
        paramDataType: BwCustomComEmitParamDataTypeEnum.object,
        remark: '',
      },
    ],
  },
  {
    key: 'drop',
    name: 'drop 触发时调用',
    params: [
      {
        paramKey: 'params',
        paramName: 'params',
        paramDataType: BwCustomComEmitParamDataTypeEnum.object,
        remark: '',
      },
    ],
  },
  {
    key: 'expand',
    name: '展开/收起节点时触发',
    params: [
      {
        paramKey: 'expandedKeys',
        paramName: 'expandedKeys',
        paramDataType: BwCustomComEmitParamDataTypeEnum.array,
        remark: '',
      },
      {
        paramKey: 'params',
        paramName: 'params',
        paramDataType: BwCustomComEmitParamDataTypeEnum.object,
        remark: '',
      },
    ],
  },
  {
    key: 'load',
    name: '节点加载完毕时触发',
    params: [
      {
        paramKey: 'loadedKeys',
        paramName: 'loadedKeys',
        paramDataType: BwCustomComEmitParamDataTypeEnum.array,
        remark: '',
      },
      {
        paramKey: 'params',
        paramName: 'params',
        paramDataType: BwCustomComEmitParamDataTypeEnum.object,
        remark: '',
      },
    ],
  },
  {
    key: 'rightClick',
    name: '响应右键点击',
    params: [
      {
        paramKey: 'params',
        paramName: 'params',
        paramDataType: BwCustomComEmitParamDataTypeEnum.object,
        remark: '',
      },
    ],
  },
  {
    key: 'select',
    name: '点击树节点触发',
    params: [
      {
        paramKey: 'selectedKeys',
        paramName: 'selectedKeys',
        paramDataType: BwCustomComEmitParamDataTypeEnum.array,
        remark: '',
      },
      {
        paramKey: 'e',
        paramName: 'e',
        paramDataType: BwCustomComEmitParamDataTypeEnum.object,
        remark: '',
      },
    ],
  },
]

/** 组件插槽 */
const comSlots: Array<BwCustomComSlotInfoModel> = [
  {
    slotType: BwCustomComSoltTypeEnum.convention,
    conventionSlotInfo: {
      slotCode: 'switcherIcon',
      slotName: '自定义树节点的展开/折叠图标',
      slotParams: [
        {
          paramKey: 'active',
          paramName: 'active',
          paramDataType: BwCustomComSlotParamDataTypeEnum.string,
          remark: '',
        },
        {
          paramKey: 'checked',
          paramName: 'checked',
          paramDataType: BwCustomComSlotParamDataTypeEnum.boolean,
          remark: '',
        },
        {
          paramKey: 'expanded',
          paramName: 'expanded',
          paramDataType: BwCustomComSlotParamDataTypeEnum.boolean,
          remark: '',
        },
        {
          paramKey: 'loading',
          paramName: 'loading',
          paramDataType: BwCustomComSlotParamDataTypeEnum.boolean,
          remark: '',
        },
        {
          paramKey: 'selected',
          paramName: 'selected',
          paramDataType: BwCustomComSlotParamDataTypeEnum.boolean,
          remark: '',
        },
        {
          paramKey: 'halfChecked',
          paramName: 'halfChecked',
          paramDataType: BwCustomComSlotParamDataTypeEnum.boolean,
          remark: '',
        },
        {
          paramKey: 'title',
          paramName: 'title',
          paramDataType: BwCustomComSlotParamDataTypeEnum.string,
          remark: '',
        },
        {
          paramKey: 'key',
          paramName: 'key',
          paramDataType: BwCustomComSlotParamDataTypeEnum.string,
          remark: '',
        },
        {
          paramKey: 'children',
          paramName: 'children',
          paramDataType: BwCustomComSlotParamDataTypeEnum.array,
          remark: '',
        },
        {
          paramKey: 'dataRef',
          paramName: 'dataRef',
          paramDataType: BwCustomComSlotParamDataTypeEnum.object,
          remark: '',
        },
        {
          paramKey: 'data',
          paramName: 'data',
          paramDataType: BwCustomComSlotParamDataTypeEnum.object,
          remark: '',
        },
        {
          paramKey: 'defaultIcon',
          paramName: 'defaultIcon',
          paramDataType: BwCustomComSlotParamDataTypeEnum.object,
          remark: '',
        },
        {
          paramKey: 'switcherCls',
          paramName: 'switcherCls',
          paramDataType: BwCustomComSlotParamDataTypeEnum.object,
          remark: '',
        },
      ],
    },
  },
  {
    slotType: BwCustomComSoltTypeEnum.convention,
    conventionSlotInfo: {
      slotCode: 'title',
      slotName: '自定义标题',
    },
  },
]

export const antTreeInfo = {
  comAttrs,
  comEmits,
  comSlots,
}
